﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using Notas.Resources;
using System.Windows.Media;
using System.Text;

namespace Notas
{
    public partial class MainPage : PhoneApplicationPage
    {
        // Constructor
        public MainPage()
        {
            InitializeComponent();
        }

        private void ApplicationBarIconButton_Click(object sender, EventArgs e)
        {
           // NavigationService.Navigate(new Uri("/View/NotaPage.xaml?Pais=" + vm.Pais + "&Ciudad=" + vm.Ciudad + "&Actualizar=" + vm.Actualizar.ToString(), UriKind.Relative));
            NavigationService.Navigate(new Uri("/View/NotePage.xaml?Action=Agregar", UriKind.Relative));

        }

        private void Grid_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {

            Notas.Model.Nota nota = ((Grid)sender).Tag as Notas.Model.Nota;

            NavigationService.Navigate(new Uri("/View/NotePage.xaml?Action=Modificar&Id="+nota.Id, UriKind.Relative));
        
        }

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
           Notas.ViewModel.NotasViewModel vm =  LayoutRoot.Resources["ViewModel"] as Notas.ViewModel.NotasViewModel;
           vm.actualizarNotas();
        }
    }
}